<?php

/**
 * @author Dingo
 */
class Form_Rotator {

    public static function generuj(Rotator $rotator, $action) {
        $formularz = '<div class="form">';
        $Config = array(
            // Default fields size
            'size' => 35,
            // Default fields error css
            'css_error' => 'fields_error',
            'template_open' => '<div class="form_row">',
            'template_label' => '<label>|LABEL|</label>',
            'template_field' => '|FIELD|',
            'template_error' => '<BR><font class="error">- |ERROR|</font>',
            'template_close' => '</div>',
            'template_line' => "\n",
            'template_field_one' => '<div class="form_row">|LABEL||FIELD|</div>'
        );


        $Form = & new Form_AuriumForm($Config);
        $formularz .= $Form->OpenForm(array('m' => 'p',
                    'action' => $action));

        $id = array(
            'type' => 'hidden',
            'name' => 'id',
            'value' => $rotator->id);

        $tresc = array(
            'label' => 'Treść:',
            'type' => 'textarea',
            'name' => 'tresc',
            'size' => array(27, 15),
            'value' => htmlspecialchars(isset($_POST['tresc']) ? $_POST['tresc'] : $rotator->tresc));

        $obrazek = array(
            'label' => 'URL obrazka:',
            'type' => 'text',
            'name' => 'obrazek',
            'value' => htmlspecialchars(isset($_POST['obrazek']) ? $_POST['obrazek'] : $rotator->obrazek));

        $data_od = array(
            'label' => 'Data od:',
            'type' => 'text',
            'extras' => 'id="data_od"',
            'name' => 'data_od',
            'value' => isset($_POST['data_od']) ? $_POST['data_od'] : $rotator->data_od);

        $data_do = array(
            'label' => 'Data do:',
            'type' => 'text',
            'extras' => 'id="data_do"',
            'name' => 'data_do',
            'value' => isset($_POST['obrazek']) ? $_POST['obrazek'] : $rotator->data_do);

        $pokazuj = array(
            'label' => 'Pokazuj:',
            'type' => 'checkbox',
            'name' => 'status',
            'value' => '1',
            'text_clickable' => true,
            'selected' => isset($_POST['status']) ? $_POST['status'] : $rotator->status);

        $przyciski = array(
            'type' => 'button',
            'subtype' => array('submit', 'button'),
            'value' => array('Wyślij', 'Anuluj'),
            'extras' => array('', 'onClick="window.location = \'/cms/rotator/\';"'),
            'alone' => true
        );



        $Form->SetData(array($tresc, $obrazek, $data_od, $data_do, $pokazuj, $id));
        $formularz .= $Form->ShowFields();
        $formularz .= $Form->OneField($przyciski);
        $formularz .= $Form->CloseForm();
        $formularz .= '</div>';
        return $formularz;
    }

}

?>
